package com.weiadmin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weiadmin.common.PageParam;
import com.weiadmin.dao.MenusDao;
import com.weiadmin.model.system.AdminMenuModel;
import com.weiadmin.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能描述
 *
 * @author: shizhongyu
 * @date: 2023年06月02日 14:16
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenusDao, AdminMenuModel> implements MenuService {

    @Autowired
    MenusDao dao;

    @Override
    public Page<AdminMenuModel> getList(PageParam pageParam){

        Page<AdminMenuModel> pager = new Page<>(pageParam.getPage(), pageParam.getLimit());
        QueryWrapper<AdminMenuModel> queryWrapper = new QueryWrapper<>();
            queryWrapper.orderByDesc("id");
        return dao.selectPage(pager, queryWrapper);
    }

    @Override
    public List<AdminMenuModel> getAll() {
        QueryWrapper<AdminMenuModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByAsc("list_order");
//        queryWrapper.eq("parent_id",0);
        List<AdminMenuModel> list = dao.selectList(queryWrapper);
        return list;
    }
}
